fix(toolbar): center the connection chip with the visible window title#1543
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1479.
Problem
After #1479 made the window title visible (
titleVisibility = .visibleon the.unifiedtoolbar), every toolbar item jumped to the right edge: the leading group, the centered connection chip, and the trailing actions all bunched up on the right, with a large empty gap after the title.Cause
The toolbar centered the connection chip (
principal) by bracketing it with two.flexibleSpaceitems. That splits the toolbar's free width in half to center the chip, which only works while the window title is hidden. With the title now drawn in the leading area of the same unified toolbar row, it takes a greedy chunk of leading width, the flexible-space split no longer balances against the real leading edge, and everything after the title collapses to the trailing edge.Fix
Use
NSToolbar.centeredItemIdentifiers(macOS 13+, the app targets 14.0), which centers an item relative to the window independently of the title and the other items. The two.flexibleSpaceitems aroundprincipalare replaced with a single.flexibleSpacethat pushes the trailing action cluster right.Layout is now: leading group on the left, connection chip centered, actions on the right, coexisting with the visible title.
centeredItemIdentifiersis applied at runtime, so it re-centers the chip even for a toolbar whose autosaved configuration still holds the old arrangement.